package com.controller;

import com.model.PlacedHospital;
import com.page.GenericPage;
import com.po.*;
import com.result.Result;
import com.service.OrdersService;
import com.service.PlacedHospitalService;
import com.vo.OrdersVO;
import com.vo.PlacedHospitalVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: chihaojie
 * @Date: 2019/5/29 16:11
 * @Version 1.0
 * @Note
 */

@Api(value = "placedHospitalApi")
@CrossOrigin
@RestController
@RequestMapping("/placedHospital")
public class PlacedHospitalController {

    @Autowired
    private PlacedHospitalService placedHospitalService;

    @ApiOperation(value = "保存", httpMethod = "POST", notes = "保存")
    @RequestMapping(value = "/save", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<PlacedHospital> save(@RequestBody PlacedHospitalPO hospitalPO) {
         return placedHospitalService.save(hospitalPO);
    }

    @ApiOperation(value = "修改", httpMethod = "POST", notes = "修改")
    @RequestMapping(value = "/modify", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<Boolean> modify(@RequestBody PlacedHospitalModifyPO placedHospitalModifyPO) {
        return placedHospitalService.modifyById(placedHospitalModifyPO);
    }



    @ApiOperation(value = "用户添加管理医院", httpMethod = "GET", notes = "用户添加管理医院")
    @RequestMapping(value = "/userAddHospital", method = RequestMethod.GET)
    public Result<Boolean> userAddHospital(@RequestParam("userId") Long userId,@RequestParam("hospitalId") Long hospitalId) {
        return placedHospitalService.userAddHospital(userId,hospitalId);
    }

    @ApiOperation(value = "用户移除管理医院", httpMethod = "GET", notes = "用户移除管理医院")
    @RequestMapping(value = "/userRemoveHospital", method = RequestMethod.GET)
    public Result<Boolean> userRemoveHospital(@RequestParam("userId") Long userId,@RequestParam("hospitalId") Long hospitalId) {
        return placedHospitalService.userRemoveHospital(userId,hospitalId);
    }

    @ApiOperation(value = "删除", httpMethod = "GET", notes = "删除")
    @RequestMapping(value = "/removeById", method = RequestMethod.GET)
    public Result<Boolean> removeById(@RequestParam Long id) {
        return placedHospitalService.removeById(id);
    }


    @ApiOperation(value = "查询", httpMethod = "POST", notes = "查询")
    @RequestMapping(value = "/queryAll", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<GenericPage<PlacedHospital>>  queryAll(@RequestBody PlacedHospitalSelectPO placedHospitalSelectPO) {
        Result<GenericPage<PlacedHospital>> genericPageResult = placedHospitalService.queryAll(placedHospitalSelectPO);
        return genericPageResult;
    }

    @ApiOperation(value = "根据id查询", httpMethod = "GET", notes = "根据id查询")
    @RequestMapping(value = "/queryById", method = RequestMethod.GET)
    public Result<PlacedHospital> queryById(@RequestParam Long id) {
        return placedHospitalService.queryById(id);
    }


    @ApiOperation(value = "根据id查询", httpMethod = "GET", notes = "根据id查询")
    @RequestMapping(value = "/queryByUserId", method = RequestMethod.GET)
    public Result<GenericPage<PlacedHospital>> queryByUserId(@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,@RequestParam(value = "pageSize" ,defaultValue = "10") Integer pageSize,@RequestParam("userId") Long userId ) {
        return placedHospitalService.queryByUserid(pageNo,pageSize,userId);
    }


    @ApiOperation(value = "绑定广告", httpMethod = "POST", notes = "绑定广告")
    @RequestMapping(value = "/bindAdvertisement", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<Boolean>  bindAdvertisement(@RequestBody AdvertisementBindPO advertisementBindPO) {
        return  placedHospitalService.bindAdvertisement(advertisementBindPO);
    }

    @ApiOperation(value = "解绑广告", httpMethod = "POST", notes = "解绑广告")
    @RequestMapping(value = "/unbindAdvertisement", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<Boolean>  bindAdvertisement(@RequestBody List<Long> hospitalIds) {
        return  placedHospitalService.unbindAdvertisement(hospitalIds);
    }
}
